package com.aspirecn.user.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.validation.Valid;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.aspirecn.user.common.RestApiConstants;
import com.aspirecn.user.domain.RequestMsg;
import com.aspirecn.user.domain.ResponseHead;
import com.aspirecn.user.domain.ResponseMsg;
import com.aspirecn.user.domain.vo.QueryUserInfoByUserNameInVo;
import com.aspirecn.user.domain.vo.QueryUserInfoByUserNameOutVo;

@RestController
public class UserController {

	Logger logger = LoggerFactory.getLogger(UserController.class);

	@RequestMapping(value = "/queryUserInfoByUserName", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<ResponseMsg<QueryUserInfoByUserNameOutVo>> queryUserInfoByUserName(@Valid @RequestBody RequestMsg<QueryUserInfoByUserNameInVo> msg, BindingResult errors) {
		ResponseMsg<QueryUserInfoByUserNameOutVo> response = new ResponseMsg<QueryUserInfoByUserNameOutVo>();
		ResponseHead rspHead = new ResponseHead();
		
		QueryUserInfoByUserNameOutVo vo = new QueryUserInfoByUserNameOutVo();
		vo.setEmail(msg.getData().getUserName() + "@126.com");
		vo.setId("123");
		vo.setUserName(msg.getData().getUserName());
		
		rspHead.setRespCode(RestApiConstants.RESPCODE_SUCCESS);
		rspHead.setRespStatus(RestApiConstants.RESPSTATUS_SUCCESS);
		rspHead.setRequestId(msg.getHead().getRequestId());
		response.setHead(rspHead);
		response.setData(vo);
		return new ResponseEntity<>(response, HttpStatus.OK);
	}
}
